/*

The Effect of Personalized Feedback on Small Enterprises' Finances in Uganda
Antonia Grohmann, Lukas Menkhoff, Helke Seitz

Table 1

*/

use "filepath\Uganda_shortterm.dta", clear



local vars  female completed_primary capcr_use inventory_v02_correct_w   sales_correct_w   

label var female "Female "
label var completed_primary "Higher education "
label var capcr_use "Capitalstock (1000 UGX)"
label var inventory_v02_correct_w "Inventory (1000 UGX)"
label var sales_correct_w "Sales (1000 UGX)"







tempname postMeans
tempfile means
postfile `postMeans' ///
     str100 varname All All2 Beauty Beauty2 Manuf Manuf2 Retail Retail2 Remain Remain2   using `means', replace
foreach v of local vars {
	local name: variable label `v'
    sum `v' if wave==8
	local n1 = round(r(N),.01)
	local mean1 = round(r(mean),.01)

	sum `v' if wave==8 & ind1==1
	local n2 = round(r(N),.01)
	local mean2 = round(r(mean),.01)
	
	sum `v' if wave==8 & ind2==1
	local n3 = round(r(N),.01)
	local mean3 = round(r(mean),.01)

	sum `v' if wave==8 & ind3==1
	local n4 = round(r(N),.01)
	local mean4 = round(r(mean),.01)
	
	sum `v' if wave==8 & ind4==1
	local n5 = round(r(N),.01)
	local mean5 = round(r(mean),.01)


    post `postMeans' ("`name'")   (`n1') (`mean1') (`n2') (`mean2') (`n3') (`mean3') (`n4') (`mean4')  (`n5') (`mean5') 
}
postclose `postMeans'


clear

use `means'
list

listtab * using "D:\users\hseitz\owncloud\DIW\01_Projekte\03_Uganda_Paper2\04_stata_output\02_desc\desc_vT1.tex", replace 

listtab * using "D:\users\hseitz\owncloud\DIW\01_Projekte\03_Uganda_Paper2\04_stata_output\02_desc\desc_vT1.tex",  ///
    rstyle(tabular) replace ///
    head("\begin{tabular}{lcccccccc}" ///
	"\hline\hline" ///
    "& \multicolumn{2}{c}{All} &  \multicolumn{2}{c}{Service Sector} & \multicolumn{2}{c}{Manufacturing Sector} & \multicolumn{2}{c}{Retail Sector}  & \multicolumn{2}{c}{Remaining}  \\" ///
	"& n & mean & n & mean & n & mean& n & mean\\" ///
	"& \multicolumn{1}{c}{(1)} & \multicolumn{1}{c}{(2)} & \multicolumn{1}{c}{(3)} & \multicolumn{1}{c}{(4)} & \multicolumn{1}{c}{(5)} & \multicolumn{1}{c}{(6)}& \multicolumn{1}{c}{(7)} & \multicolumn{1}{c}{(8)}\\" ///
	"\hline" ///
    ) ///
    foot("\hline\hline" "\end{tabular}")


			

